<?php
include("./config.php");
include("./utils.php");
//checkLogin();
?>
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>添加软件</title>
  <?php include 'scripts-inc.php' ?>

  <script>
  $(function(){
    $("#search-container").hide();

    $("#tlogo").change(function(){
      var tlogo = $("#tlogo").val();
      $("#logo-img").attr("src", tlogo);
    });

    $("#add-app").click(function(){
      var data = {
        userid:gUserID,
        skin:$("#tskin").val(),
        des:$("#tdes").val(),
        name:$("#tname").val(),
        des_en:$("#tdes_en").val(),
        name_en:$("#tname_en").val(),
        logo:$("#tlogo").val(),
        op:'add-app'
      };

      if((!data.name && !data.name_en) 
        || (data.name.length < 2 && data.name_en.length < 2) ){
        show_msg("#content", "name is null");
        return;
      }


      show_msg("#content", "提交中...");
      $.post("update-data.php", data, function(msg){
        show_msg("#content", "完成");
        $("#add-app").hide();
      });
    });

  });//end of $(function(){

  </script>
</head>
<body>
<!-- template -->
<!-- end of template -->


<div id="wrapper">
<div id="container">
<!-- .................................................... -->

<div id="nav_data_src">
    <?php include 'navbars-inc.php' ?>
</div>

<div id="tcontainer" class="center">
<div class="container-fluid">

    <div class="form-group row">
      <label for="tname" class="col-xs-3 col-sm-1 col-md-1 col-lg-1 control-label">软件名称</label>
      <div class="col-xs-7 col-sm-6 col-md-6 col-lg-6">
        <input type="" class="form-control" id="tname" name="tname" placeholder="">
      </div>
    </div>
    <div class="form-group row">
      <label for="tdes" class="col-xs-3 col-sm-1 col-md-1 col-lg-1 control-label">说明</label>
      <div class="col-xs-7 col-sm-6 col-md-6 col-lg-6">
        <textarea class="form-control" id="tdes" rows="3" name="tdes" placeholder=""></textarea>
      </div>
    </div>

    <!-- English -->
    <div class="form-group row">
      <label for="tname_en" class="col-xs-3 col-sm-1 col-md-1 col-lg-1 control-label">Name</label>
      <div class="col-xs-7 col-sm-6 col-md-6 col-lg-6">
        <input type="" class="form-control" id="tname_en" name="tname_en" placeholder="">
      </div>
    </div>
    <div class="form-group row">
      <label for="tdes_en" class="col-xs-3 col-sm-1 col-md-1 col-lg-1 control-label">Description</label>
      <div class="col-xs-7 col-sm-6 col-md-6 col-lg-6">
        <textarea class="form-control" id="tdes_en" rows="3" name="tdes_en" placeholder=""></textarea>
      </div>
    </div>

    <div class="form-group row">
      <label for="tskin" class="col-xs-3 col-sm-1 col-md-1 col-lg-1 control-label">皮肤</label>
      <div class="col-xs-7 col-sm-6 col-md-6 col-lg-6">
        <input type="" class="form-control" id="tskin" name="tskin" placeholder="">
        <a class="btn btn-lg list-group-item-default" onclick="$('#tskin').val(0)">0</a>
        <a class="btn btn-lg list-group-item-danger" onclick="$('#tskin').val(1)">1</a>
        <a class="btn btn-lg list-group-item-info" onclick="$('#tskin').val(2)">2</a>
        <a class="btn btn-lg list-group-item-warning" onclick="$('#tskin').val(3)">3</a>
        <a class="btn btn-lg list-group-item-success" onclick="$('#tskin').val(4)">4</a>
        <a class="btn btn-lg list-group-item-primary" onclick="$('#tskin').val(5)">5</a>
      </div>
    </div>

    <div class="form-group row">
      <label for="tlogo" class="col-xs-3 col-sm-1 col-md-1 col-lg-1 control-label">Logo</label>
      <div class="col-xs-7 col-sm-6 col-md-6 col-lg-6">
        <input type="" class="form-control" id="tlogo" name="tlogo" placeholder="">
        <img id="logo-img" style='max-width:128px;_width:expression(this.width > 128 ? "128px" : this.width);' src="" />
      </div>
    </div>

  <div class="clearfix"></div>
  <div class="form-group row">
      <a href="./index.php" class="btn btn-lg btn-warning col-xs-4 col-sm-2 col-md-2 col-lg-2 text-center" >返回首页</a>
      <a href="javascript:window.opener=null;window.open('','_self');window.close();"
       class="lang-close-page btn btn-lg btn-danger col-xs-4 col-sm-2 col-md-2 col-lg-2 text-center" 
       id="goback-app" >关闭本页</a>
      <button id="add-app" href="#" class="btn btn-lg btn-success col-xs-2 col-sm-2 col-md-2 col-lg-2 text-center" >提交</button>
  </div>
<div class="form-group row">
    <div class="col-xs-7 col-sm-4 col-md-4 col-lg-4 text-center">
      <div id="content"></div>
    </div>
</div>
</div>


</div> <!-- end of tcontainer -->

<!-- .................................................... -->
</div><!-- end of container -->
</div><!-- end of wrapper -->
</body>
</html>
